package com.google.gwt.sample.dynatablerf.server.domain;

import java.io.Serializable;

import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.NamedQuery;

import com.google.gwt.sample.dynatablerf.shared.MaterialProxy.TipoMaterial;

@Entity
@NamedQuery(name = Material.MATERIAL_PESQUISAR, query = "SELECT t FROM Material t WHERE "
		+ "(:id is null or t.id = :id) "
		+ "AND (:codigoMaterial is null or t.codigoMaterial like :codigoMaterial)")
public class Material extends AbstractEntity implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public static final String MATERIAL_PESQUISAR = "Material_Pesquisar";

	private String codigoMaterial;

	private String descricao;

	private String tuc;

	private String a1;

	private String a2;

	private String a3;

	private String a4;

	private String a5;

	private String a6;

	@Enumerated(EnumType.STRING)
	private TipoMaterial tipoMaterial;

	public Material() {
		super();
	}

	public Material(String codigoMaterial, String descricao,
			TipoMaterial tipoMaterial) {
		this(codigoMaterial, descricao, null, null, null, null, null, null,
				null, null, tipoMaterial);
	}

	public Material(String codigoMaterial, String descricao, String tuc,
			String a1, String a2, String a3, String a4, String a5, String a6,
			TipoInstalacao tipoInstalacao, TipoMaterial tipoMaterial) {
		this();
		this.codigoMaterial = codigoMaterial;
		this.descricao = descricao;
		this.tuc = tuc;
		this.a1 = a1;
		this.a2 = a2;
		this.a3 = a3;
		this.a4 = a4;
		this.a5 = a5;
		this.a6 = a6;
		this.tipoMaterial = tipoMaterial;
	}

	public String getCodigoMaterial() {
		return codigoMaterial;
	}

	public void setCodigoMaterial(String codigoMaterial) {
		this.codigoMaterial = codigoMaterial;
	}

	public String getDescricao() {
		return descricao;
	}

	public void setDescricao(String descricao) {
		this.descricao = descricao;
	}

	public String getTuc() {
		return tuc;
	}

	public void setTuc(String tuc) {
		this.tuc = tuc;
	}

	public String getA1() {
		return a1;
	}

	public void setA1(String a1) {
		this.a1 = a1;
	}

	public String getA2() {
		return a2;
	}

	public void setA2(String a2) {
		this.a2 = a2;
	}

	public String getA3() {
		return a3;
	}

	public void setA3(String a3) {
		this.a3 = a3;
	}

	public String getA4() {
		return a4;
	}

	public void setA4(String a4) {
		this.a4 = a4;
	}

	public String getA5() {
		return a5;
	}

	public void setA5(String a5) {
		this.a5 = a5;
	}

	public String getA6() {
		return a6;
	}

	public void setA6(String a6) {
		this.a6 = a6;
	}

	public TipoMaterial getTipoMaterial() {
		return tipoMaterial;
	}

	public void setTipoMaterial(TipoMaterial tipoMaterial) {
		this.tipoMaterial = tipoMaterial;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((a1 == null) ? 0 : a1.hashCode());
		result = prime * result + ((a2 == null) ? 0 : a2.hashCode());
		result = prime * result + ((a3 == null) ? 0 : a3.hashCode());
		result = prime * result + ((a4 == null) ? 0 : a4.hashCode());
		result = prime * result + ((a5 == null) ? 0 : a5.hashCode());
		result = prime * result + ((a6 == null) ? 0 : a6.hashCode());
		result = prime * result
				+ ((codigoMaterial == null) ? 0 : codigoMaterial.hashCode());
		result = prime * result
				+ ((descricao == null) ? 0 : descricao.hashCode());
		result = prime * result
				+ ((tipoMaterial == null) ? 0 : tipoMaterial.hashCode());
		result = prime * result + ((tuc == null) ? 0 : tuc.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Material other = (Material) obj;
		if (a1 == null) {
			if (other.a1 != null)
				return false;
		} else if (!a1.equals(other.a1))
			return false;
		if (a2 == null) {
			if (other.a2 != null)
				return false;
		} else if (!a2.equals(other.a2))
			return false;
		if (a3 == null) {
			if (other.a3 != null)
				return false;
		} else if (!a3.equals(other.a3))
			return false;
		if (a4 == null) {
			if (other.a4 != null)
				return false;
		} else if (!a4.equals(other.a4))
			return false;
		if (a5 == null) {
			if (other.a5 != null)
				return false;
		} else if (!a5.equals(other.a5))
			return false;
		if (a6 == null) {
			if (other.a6 != null)
				return false;
		} else if (!a6.equals(other.a6))
			return false;
		if (codigoMaterial == null) {
			if (other.codigoMaterial != null)
				return false;
		} else if (!codigoMaterial.equals(other.codigoMaterial))
			return false;
		if (descricao == null) {
			if (other.descricao != null)
				return false;
		} else if (!descricao.equals(other.descricao))
			return false;
		if (tipoMaterial != other.tipoMaterial)
			return false;
		if (tuc == null) {
			if (other.tuc != null)
				return false;
		} else if (!tuc.equals(other.tuc))
			return false;
		return true;
	}

}
